package com.treasure.mall.zbqmallapi.vo.auction;

import com.treasure.mall.biz.entity.auction.AuctionSessionPO;
import com.treasure.mall.biz.vo.BaseVO;
import com.treasure.mall.zbq.common.Jsr310Utils;
import com.treasure.mall.zbq.common.ienum.auction.AuctionEnums;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * @author allan
 * @version 1.0.0
 * @date 2020/7/17
 */
@Data
@NoArgsConstructor
public class AuctionSessionBaseVO implements BaseVO {
    private static final long serialVersionUID = 7531160679389723639L;
    private String startTime;
    private String endTime;
    private AuctionEnums.AuctionStatus auctionStatus;


    private Long sessionId;
    /**
     * 起拍价
     */
    private BigDecimal startingPrice;
    /**
     * 单位加价幅度
     */
    private BigDecimal unitIncrease;
    /**
     * 保证金
     */
    private BigDecimal securityDeposit;
    /**
     * 当前最高价格
     */
    private BigDecimal topPrice;
    private boolean delay;


    public AuctionSessionBaseVO(AuctionSessionPO sessionPO) {
        this.sessionId = sessionPO.getId();
        this.auctionStatus = sessionPO.getAuctionStatus();
        this.startTime = Jsr310Utils.DateTime.asString(sessionPO.getStartTime());
        this.endTime = Jsr310Utils.DateTime.asString(sessionPO.getEndTime());
        this.startingPrice = sessionPO.getStartingPrice();
        this.unitIncrease = sessionPO.getUnitIncrease();
        this.securityDeposit = sessionPO.getSecurityDeposit();
        if (sessionPO.getWinner() == null) {
            this.topPrice = startingPrice;
        } else {
            this.topPrice = sessionPO.getWinner().getBidAmount();
        }
        this.delay = sessionPO.isDelay();
    }
}
